package game.manager
{
	public class ConfigManager
	{
		public function ConfigManager()
		{
		}
		
		private static var _instance:ConfigManager;
		public static function get instance():ConfigManager
		{
			if (!_instance)
				_instance = new ConfigManager();
			return _instance;
		}
		
		public function setData(data:XML):void
		{
			_servHost = data.connect.host;
			_servPort = data.connect.port;
			
			_modules = {};
			for each(var module:XML in data.modules.item)
			{
				var moduleItem:Object = {};
				moduleItem.title = module.@title;
				moduleItem.name = module.@name;
				moduleItem.url = module.@url;
				_modules[moduleItem.title] = moduleItem;
			}
		}
		
		private var _servHost:String;
		private var _servPort:uint;
		private var _modules:Object;
		
		public function getModules():Object
		{
			return _modules;
		}
		
		public function getModuleByTitle(title:String):Object
		{
			return _modules[title];
		}
		
		public function get servHost():String
		{
			return _servHost;
		}
		
		public function get servPort():uint
		{
			return _servPort;
		}
	}
}